<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统首页</title>
    <link rel="stylesheet" type="text/css" href="css/el-index.css"/>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<div id="one">
    <el-container id="father">
        <el-header>
            <div>
                在线投票系统
            </div>
            <div>
                欢迎您，{{user.nickname}}
            </div>
        </el-header>
        <el-container id="left">
            <el-aside style="width: 200px">
                <div class="touxiang">
                    <p>
                        <img :src="'http://localhost:8080'+user.userImg">
                    </p>
                    <p>
                        {{user.nickname}}
                    </p>
                </div>
                <el-menu>
                    <el-menu-item> <a href="votelist.html" target="chuangKou">投票活动列表</a></el-menu-item>
                    <el-menu-item> <a href="voteadd.html" target="chuangKou">新增投票活动</a></el-menu-item>
                    <el-menu-item> <a href="candidatelist.html" target="chuangKou">候选人列表</a></el-menu-item>
                    <el-menu-item> <a href="userlist.html" target="chuangKou">用户列表</a></el-menu-item>
                </el-menu>
            </el-aside>
            <el-main>
                <iframe name="chuangKou" src="votelist.html">

                </iframe>
            </el-main>
        </el-container>
    </el-container>
</div>
<script src="js/vue.js"></script>
<script src="js/el-index.js"></script>
<script src="js/axios.min.js"></script>
<script>
    //创建vue对象
    var app = new Vue({
        //挂载点
        el:"#father",
        //数据
        data:{
            user:{}
        },
        //方法
        methods:{

        },
        //当 当前页面 被创建时，要执行的方法
        created(){
            console.log("查询session中的用户")
            var _this = this;
            //发起ajax请求，获取当前session中的user
            axios.get("user/getUser").then(
                function (res) {
                    if(res.data.message =="200"){//session中有用户，返回200。显示用户信息
                        _this.user = res.data.user;
                        console.log(_this.user)
                    }else{//session中无用户，返回202。跳转到 login.html
                        location.href="login.html";
                    }
                }
            )
        }
    })
</script>
</body>
</html>